package cn.ccenjie.wsy.social.alipay.connet;

import cn.ccenjie.wsy.social.alipay.api.Alipay;
import cn.ccenjie.wsy.social.alipay.api.AlipayImpl;
import cn.ccenjie.wsy.social.alipay.api.AlipayOauth2Template;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;

public class AlipayServiceProvider extends AbstractOAuth2ServiceProvider<Alipay> {

    private String appId;

    private static final String URL_AUTHORIZE = "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm";

    private static final String URL_ACCESS_TOKEN = "https://openapi.alipay.com/gateway.do";

    public AlipayServiceProvider(String appId, String secret) {
        super(new AlipayOauth2Template(appId, secret, URL_AUTHORIZE, URL_ACCESS_TOKEN));
        this.appId = appId;
    }

    @Override
    public Alipay getApi(String authToken) {
        return new AlipayImpl(appId, authToken);
    }
}
